package com.control.qct.businesssteward.adapter;

import android.support.annotation.Nullable;

import com.control.qct.businesssteward.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.control.qct.businesssteward.model.StoreModel;

import java.util.List;

/**
 * Created by Administrator on 2017/12/12 0012.
 */

public class ShopSelectAdapter extends BaseQuickAdapter<StoreModel, BaseViewHolder> {
    private int mId;
    private int mPosition = -1;

    public ShopSelectAdapter(@Nullable List<StoreModel> data, int id) {
        super(R.layout.rv_pop_shop_select_item, data);
        mId = id;
    }

    @Override
    protected void convert(BaseViewHolder holder, StoreModel item) {
        holder.setText(R.id.cb_shop_select, item.getTitle());
        if (mId == 1) {
            holder.setChecked(R.id.cb_shop_select, mPosition == holder.getAdapterPosition() && item.isChecked());
        } else {
            holder.setChecked(R.id.cb_shop_select, item.isChecked());
        }

    }

    public void setPosition(int position) {
        mPosition = position;
        notifyDataSetChanged();
    }
}
